home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 076-100 / 091 / util / mytime.c < prev    next >
C/C++ Source or Header  |  1995-03-18  |  2KB  |  93 lines

  1. #include "adltypes.h"
  2.  
  3. #if AMIGA
  4. #include <libraries/dos.h>
  5.  
  6. #define MINUTES_PER_DAY    (60 * 24)
  7. #define TICKS_PER_MINUTE (60 * TICKS_PER_SECOND)
  8.  
  9. int32
  10. mytime()
  11. {
  12.     struct DateStamp
  13.     ds;
  14.     long
  15.     retval;
  16.  
  17.     DateStamp( &ds );
  18.     retval = MINUTES_PER_DAY * ds.ds_Days + ds.ds_Minute;
  19.     retval = TICKS_PER_MINUTE * retval + ds.ds_Tick;
  20.     return retval;
  21. }
  22.  
  23. checkbreak( rout )
  24. int
  25.     (*rout)();
  26. {
  27.     if( SetSignal( 0L, 0L ) & SIGBREAKF_CTRL_C ) {
  28.     /* We were signalled - call the routine */
  29.     (*rout)();
  30.     /* Reset the signal */
  31.     (void)SetSignal( 0L, SIGBREAKF_CTRL_C );
  32.     }
  33. }
  34.  
  35. #endif
  36.  
  37.  
  38. #if MSDOS
  39. #include <dos.h>
  40. #undef time
  41.  
  42. int32
  43. mytime( )
  44. {
  45.     int32 temp[ 3 ];        /* Buffer */
  46.  
  47.     time( (char *)temp, 0 );    /* Get a bcd version of time of day */
  48.     return temp[ 0 ];        /* And pretend that it fits in one long */
  49. }
  50.  
  51. checkbreak( rout )
  52. int
  53.     (*rout)();
  54. {
  55.     /* No convenient way of doing this from C under MS-DOS.  Sigh. */
  56.     union REGS
  57.     reglist;
  58.  
  59.     reglist.h.ah = 0x0b;        /* Check keyboard status */
  60.     int86( 0x21, ®list, ®list );
  61.     /* If the keyboard buffer contained CTRL-C, the program MIGHT exit */
  62. }
  63. #endif
  64.  
  65.  
  66. #if UNIX
  67. #include <signal.h>
  68. static int
  69.     (*_break_rout)();
  70.  
  71. static
  72. _do_break()
  73. {
  74.     /* This routine is the one which actually gets called when signalled */
  75.     signal( SIGINT, SIG_IGN );        /* Ignore this signal until ready */
  76.     (*_break_rout)();            /* Call the routine */
  77.     signal( SIGINT, _do_break );    /* Ready */
  78. }
  79.  
  80.  
  81. checkbreak( rout )
  82. int
  83.     (*rout)();
  84. {
  85.     if( _break_rout == (int (*)())0 )
  86.     signal( SIGINT, _do_break );
  87.     _break_rout = rout;
  88. }
  89.  
  90. #endif
  91.  
  92. /*** EOF mytime.c ***/
  93.